import { request } from '@umijs/max';
// 查询账户列表
export async function getSingleAccountList(params: { signStatus: string }) {
  return request('/merchant/safe-pay-book-account/list', {
    method: 'post',
    data: params,
    getResponse: true,
  });
}

/**转账记录 */

// 查询批次明细
export async function getDetailList(params: {
  pageSize: number | string;
  pageNo: number | string;
  count?: any;
  batchId?: number;
  importBizNo?: any;
  identity?: any;
  status?: string;
}) {
  return request('/merchant/safe-pay-order/search', {
    method: 'post',
    data: params,
    getResponse: true,
  });
}

export type SearchParams = {
  pageSize: number | string;
  pageNo: number | string;
  importBatchNo: string;
  status: string;
  statusList?: any;
  alipayNickName: string;
};
// 查询转账记录
export async function searchSafePayBatch(params: SearchParams) {
  return request('/merchant/safe-pay/search', {
    method: 'post',
    data: params,
    getResponse: true,
  });
}
// 关闭
export async function closeItem(id: number) {
  return request(`/merchant/safe-pay/close-batch?id=${id}`, {
    method: 'post',
    getResponse: true,
  });
}

// 查询转账统计
export async function getChangeStatistic(params: {
  pageSize: number | string;
  pageNo: number | string;
  minDay: string;
  maxDay: string;
}) {
  return request('/merchant/user-safe-pay-trans-stat/search', {
    method: 'post',
    data: params,
    getResponse: true,
  });
}

// 单笔转账
export async function singleChange(params: {
  alipayNickName: string;
  transAmount: number;
  remark: string;
  identity: string;
  type: number;
  name: string;
}) {
  return request('/merchant/safe-pay/manual-import-safe-pay-trans', {
    method: 'post',
    data: params,
    getResponse: true,
  });
}

// 批量转账上传
export async function importFile() {
  return request('/merchant/excel/import-safe-pay-trans', {
    method: 'post',
    getResponse: true,
  });
}

// 转账时获取验证码
export async function getCaptchaBeforeChange(params: {
  batchId: string;
  useSpareReceiveMobile: any;
}) {
  return request('/merchant/safe-pay/check-code', {
    method: 'get',
    params,
    getResponse: true,
  });
}

// 最终确认打款
export async function confirmPayUp(params: {
  importBatchNo: string;
  checkCode: string;
  authMethod: number;
  payPassword: string;
}) {
  return request('/merchant/safe-pay/batch-trans', {
    method: 'post',
    data: params,
    getResponse: true,
  });
}

// 发起转账时查询数据
export async function getChangeItemData(params: { id: string }) {
  return request('/merchant/safe-pay/get-batch', {
    method: 'get',
    params,
    getResponse: true,
  });
}

// 转账界面备付金充值
export async function rechargeAmount(params: {
  alipayNickName: string;
  transAmount: string;
}) {
  return request('/merchant/safe-pay/charge', {
    method: 'post',
    data: params,
    getResponse: true,
  });
}

// 回单
export async function retOrder(params: { id: string }) {
  return request('/merchant/safe-pay-order/apply-receipt', {
    method: 'post',
    data: params,
    getResponse: true,
  });
}